package com.hsoft.zhxy.app.xtgl_02_01.controller;

import com.alibaba.fastjson.JSONObject;
import com.hsoft.zhxy.app.common.model.entity.JcqxBm;
import com.hsoft.zhxy.app.common.model.entity.JcqxYhbm;
import com.hsoft.zhxy.app.xtgl_02_01.model.query.BmxxQUERY;
import com.hsoft.zhxy.app.xtgl_02_01.model.vo.JcqxBmDrVO;
import com.hsoft.zhxy.app.xtgl_02_01.model.vo.JcqxBmListVO;
import com.hsoft.zhxy.app.xtgl_02_01.service.JcqxBmService;
import com.hsoft.zhxy.app.xtgl_02_01.service.JcqxYhbmService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

@Api(tags = "xtgl_02_01 部门")
@Log4j2
@Validated
@RestController
@RequestMapping(value = "/xtgl_02_01/jcqxBm/", produces = "application/json;charset=UTF-8")
public class JcqxBmController {

    @Autowired
    private JcqxBmService jcqxBmService;
    @Autowired
    private JcqxYhbmService jcqxYhbmService;

    @ApiOperation(value = "通过部门码查询部门数据", notes = "通过部门码查询部门数据")
    @GetMapping("findBmByBmm")
    public JSONObject findBmByBmm(JcqxBm jcqxBm) {
        return jcqxBmService.findBmByBmm(jcqxBm);
    }


    @ApiOperation(value = "查询部门树列表数据", notes = "查询部门树列表数据")
    @GetMapping("findBmList")
    public JSONObject findBmList(JcqxBm jcqxBm) {
        return jcqxBmService.findBmList(jcqxBm);
    }
    
    
    @ApiOperation(value = "通过部门码查询部门分页列表数据", notes = "通过部门码查询部门分页列表数据")
    @GetMapping("findBmListByPageFbmm")
    public JSONObject findBmListByPageFbmm(@Valid BmxxQUERY bmxxQuery) {
        return jcqxBmService.findBmListByPageFbmm(bmxxQuery);

    }

    @ApiOperation(value = "通过部门码查询用户分页列表数据", notes = "通过部门码查询用户分页列表数据")
    @GetMapping("findYhListByPageBmm")
    public JSONObject findYhListByPageBmm(@Valid BmxxQUERY bmxxQuery) {
        return jcqxBmService.findYhListByPageBmm(bmxxQuery);

    }

    @ApiOperation(value = "通过部门码查询用户数据", notes = "通过部门码查询用户数据")
    @GetMapping("findYhListByBmm")
    public JSONObject findYhListByBmm(@Valid JcqxBm jcqxBm) {
        return jcqxBmService.findYhListByBmm(jcqxBm);

    }


    @ApiOperation(value = "新增部门", notes = "新增部门")
    @PostMapping("addBm")
    public JSONObject addBm(@RequestBody @Valid JcqxBm jcqxBm) {
        return jcqxBmService.addBm(jcqxBm);
    }
    
    
    @ApiOperation(value = "修改部门", notes = "修改部门")
    @PostMapping("update")
    public JSONObject update(@RequestBody @Valid JcqxBm jcqxBm) {
        return jcqxBmService.update(jcqxBm);
    }

    @ApiOperation(value = "删除", notes = "删除")
    @PostMapping("deleteBmBatch")
    public JSONObject deleteBmBatch( @RequestBody JcqxBmListVO jcqxBmListVO) {
        return jcqxBmService.deleteBatch(jcqxBmListVO);
    }


    @ApiOperation(value = "用户调入", notes = "用户调入")
    @PostMapping("drBmBatch")
    public JSONObject drBmBatch( @RequestBody @Valid JcqxBmDrVO jcqxBmDrVO) {
        return jcqxBmService.drBmBatch(jcqxBmDrVO);
    }

    @ApiOperation(value = "用户调入", notes = "用户调入")
    @PostMapping("deleteYhBm")
    public JSONObject deleteYhBm(@RequestBody JcqxYhbm jcqxYhbm) {
        return jcqxYhbmService.delete(jcqxYhbm);
    }


    // 各方法命名需要以 find、add、update、delete开头，遵循驼峰原则


}